package ee.metadataUtils.guice;

import java.lang.reflect.Type;

import javax.inject.Inject;

import com.google.inject.Injector;
import com.google.inject.Key;

import ee.metadataUtils.ObjectFactory;

public class GuiceObjectFactory implements ObjectFactory {

	private Injector _injector;

	@Inject
	public GuiceObjectFactory(Injector injector) {
		_injector = injector;
	}
	
	@Override
	public Object create(Type type) throws InstantiationException {
		return _injector.getInstance(Key.get(type));
	}

}
